package com.lvhx.springboot.springbatch.batch;

import org.springframework.jdbc.support.incrementer.DataFieldMaxValueIncrementer;

import javax.sql.DataSource;

public class DefaultDataFieldMaxValueIncrementerFactory extends org.springframework.batch.item.database.support.DefaultDataFieldMaxValueIncrementerFactory {
    protected DataSource dataSource;

    public DataSource getDataSource() {
        return dataSource;
    }

    public void setDataSource(DataSource dataSource) {
        this.dataSource = dataSource;
    }

    public DefaultDataFieldMaxValueIncrementerFactory(DataSource dataSource) {
        super(dataSource);
        setDataSource(dataSource);
    }

    @Override
    public DataFieldMaxValueIncrementer getIncrementer(String incrementerType, String incrementerName) {
        return new ObSequenceMaxValueIncrementer(dataSource, incrementerName);
    }

    @Override
    public boolean isSupportedIncrementerType(String incrementerType) {
        return true;
    }
}
